# Maintainer: Jakub Panek <me@panekj.dev>
pkgname=buildkit
pkgver=0.12.4
pkgrel=0
pkgdesc="Concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit"
url="https://github.com/moby/buildkit"
arch="all"
license="Apache-2.0"
depends="containerd"
makedepends="go"
subpackages="$pkgname-openrc buildctl"
source="$pkgname-$pkgver.tar.gz::https://github.com/moby/buildkit/archive/refs/tags/v$pkgver.tar.gz
	buildkitd.initd
	buildkitd.confd
	"
options="!check" # needs to mount various things as root

export CGO_ENABLED=0
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	mkdir -p out
	go build -v \
		-ldflags="
		-X github.com/moby/buildkit/version.Version=$pkgver \
		-X github.com/moby/buildkit/version.Revision=alpine \
		" \
		-o out \
		./cmd/...
}

package() {
	install -Dm755 ./out/* \
		-t "$pkgdir"/usr/bin
	install -Dm755 "$srcdir"/buildkitd.initd \
		"$pkgdir"/etc/init.d/buildkitd
	install -Dm644 "$srcdir"/buildkitd.confd \
		"$pkgdir"/etc/conf.d/buildkitd
}

buildctl() {
	pkgdesc="$pkgdesc (cli frontend)"
	amove usr/bin/buildctl
}

sha512sums="
ee20e202303b274d6f71339f792b68c469cba2e574952c38dc1fb4a76cc9ad8fcf629043002432652c3fdf8bd57df09a63abfedc8fbf56d673130cd1f55e551e  buildkit-0.12.4.tar.gz
01007221e6aab7a9f9565b48d2a338b2a72508234c7874a4aeaf9fd9181a19ffebe6374560bbae0262b009643b1fb49fb51b0f8006540355ae0f42fbaad5dd59  buildkitd.initd
44efad35c5867266a84246cf49afd2c4d775a530409397c817c8026873c75686432388325cd7654d939e8bfeceeada9112f3dd814ae5d95d4470373c3aa6dc3e  buildkitd.confd
"
